package com.wuyou.designPatterns.singleton;

/**
 * 方法锁：防止多线程破坏单例
 */
public class Singleton2 {

    private static Singleton2 singleton2;

    private Singleton2(){}


    public static synchronized Singleton2 getInstance(){
        if (singleton2 == null) {
            singleton2 = new Singleton2();
        }
        return singleton2;
    }
}
